﻿@model ScmSafetyassessmentViewModel
@{
    Layout = null;
    ViewBag.Title = "安全考核列表";
    int state = 1;
}
<div class="page" style="border-top: 1px solid #b8d0d6;" layouth="1">
    @using (Html.BeginForm("SplitPage", "ScmSafeAssessment", null, FormMethod.Post, new { id = "pagerForm", onsubmit = "return navTabSearch(this);" }))
    {
        <input type="hidden" name="pageNum" value="1" />
        <input type="hidden" name="numPerPage" value="@(ViewBag.numPerPage)" />
        <ul class="searchBar">
            <li><span>安全考核：</span>
                <input type="text" name="iput_title" value="@(ViewBag.iput_title)" />
            </li>
            <li><span>考核日期：</span>
                <input type="text" name="iput_timestart" value="@(ViewBag.iput_timestart)" class="date" />
                <span>- </span>
                <input type="text" name="iput_timeend" value="@(ViewBag.iput_timeend)" class="date" />
            </li>
            <li>
                <span>考核类型：</span>
                <select name="sel_type">
                    <option value="">所有考核类型</option>
                    @foreach (var item in Model.TheSafetyconstructiondicList)
                    {
                        <option value="@(item.Scd_ID)">@item.Scd_Name</option> 
                    }
                </select>
            </li>
            <li>
                <button type="submit" class="btn btn-success btn-xs">
                    搜索</button>
            </li>
        </ul>
    }
    <div class="panelBar" style="border-top: none;">
        <ul class="toolBar">
            <li>
                @Html.PermissionButton("SafetyConstruction.ScmSafeAssessment.Create", "SafetyConstruction_SafeAssessment_SafeAssessmentAdd",
                    Url.Action("SafeAssessmentAdd", "ScmSafeAssessment"),
                    "添加",
                    new Dictionary<string, object>
                    {
                        {"class","add"},{"rel","aqkh_add"} ,{"mask","true"},{"target","dialog"},{"width","1090"},{"height","660"}
                    })
            </li>
            <li>
                @Html.PermissionButton("SafetyConstruction.ScmSafeAssessment.Delete", "SafetyConstruction_SafeAssessment_SafeAssessmentDelete",
                    Url.Action("SafeAssessmentDelete", "ScmSafeAssessment", new { ids = "{tr_id}" }),
                    "删除",
                    new Dictionary<string, object>
                    {
                        {"class","delete"},{"rel","ids"},{"title","确定要删除这些记录吗?"},{"target","ajaxTodo"},{"postType","string"}
                    })
            </li>
            <li>
                @Html.PermissionButton("SafetyConstruction.ScmSafeAssessment.Edit", "SafetyConstruction_SafeAssessment_SafeAssessmentEdit",
                    Url.Action("SafeAssessmentEdit", "ScmSafeAssessment", new { id = "{tr_id}" }),
                    "修改",
                    new Dictionary<string, object>
                    {
                        {"class","edit"},{"rel","aqkh_edit"} ,{"mask","true"},{"target","dialog"},{"width","1090"},{"height","660"},{"warn","请选择一条信息!"}
                    })
            </li>
            <li>
                @Html.PermissionButton("SafetyConstruction.ScmSafeAssessment.Detail", "SafetyConstruction_SafeAssessment_SafeAssessmentDetail",
                    Url.Action("SafeAssessmentDetail", "ScmSafeAssessment", new { id = "{tr_id}" }),
                    "查看",
                    new Dictionary<string, object>
                    {
                        {"class","detail"},{"rel","aqkh_detail"} ,{"mask","true"},{"target","dialog"},{"width","1090"},{"height","660"},{"warn","请选择一条信息!"}
                    })
            </li>
            <li class="line">line</li>
            <li>
                @Html.PermissionButton("SafetyConstruction.ScmSafeAssessment.Report", "SafetyConstruction_SafeAssessment_SafeAssessmentReport",
                    Url.Action("SafeAssessmentReport", "ScmSafeAssessment", new { id = "{tr_id}" }),
                    "下发",
                    new Dictionary<string, object>
                    {
                        {"class","send"},{"rel","aqkh_report"} ,{"mask","true"},{"target","dialog"},{"width","1090"},{"height","660"},{"warn","请选择一条信息!"},{"title","上报得分"}
                    })
            </li>
        </ul>
    </div>
    <table class="table" width="100%" layouth="122">
        <thead>
            <tr>
                <th width="20" align="center" style="display: none">
                    <input type="checkbox" group="ids" class="checkboxCtrl">
                </th>
                <th width="30" align="center">序号
                </th>
                <th width="200" align="center">安全考核
                </th>
                <th width="100" align="center">考核机构
                </th>
                <th width="100" align="center">考核类型
                </th>
                <th width="100" align="center">考核日期
                </th>
                <th width="100" align="center">得分上报状态
                </th>
            </tr>
        </thead>
        <tbody>
            @{ int num = (ViewBag.pageNum - 1) * ViewBag.numPerPage;}
            @foreach (ScmSafetyassessmentInfo info in Model.TheSafetyassessmentList)
            {
                num += 1;

                <tr target="tr_id" rel="@info.Sa_ID" align="center" data-state="@info.Sa_State" data-sole="ScmSafeAssessmentList">
                    <td style="display: none">
                        <input name="ids" value="@info.Sa_ID" type="checkbox">
                    </td>
                    <td align="center">@num
                    </td>
                    <td align="center">
                        <a target="navTab" title="查看" href="@Url.Action("SafeAssessmentDetail", "ScmSafeAssessment", new { id = info.Sa_ID })">@info.Sa_Title</a>
                    </td>
                    <td align="center">@info.Sa_DepartmentName
                    </td>
                    <td align="center">@Model.GetTypeName(info.Scd_ID)
                    </td>
                    <td align="center">@info.Sa_AssessmentTime.ToString("yyyy-MM-dd")
                    </td>
                    <td align="center">@(info.Sa_State == 0 ? "未下发" : "已下发")
                    </td>
                </tr>
            }
        </tbody>
    </table>
    <div class="panelBar" style="border-bottom: none;">
        <div class="pages" style="float: right">
            <span>显示</span>
            <select class="comsplitpage" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
                <option value="10" @(ViewBag.numPerPage == 10 ? "selected='selected'" : "")>10</option>
                <option value="20" @(ViewBag.numPerPage == 20 ? "selected='selected'" : "")>20</option>
                <option value="50" @(ViewBag.numPerPage == 50 ? "selected='selected'" : "")>50</option>
            </select>
            <span>条，共@(ViewBag.pagenumshown)页,@(ViewBag.totalcount)条</span>
        </div>
        <div class="pagination"  style="margin:0px;float:left; margin-left:35%" targettype="navTab" totalcount="@(ViewBag.totalcount)" numperpage="@(ViewBag.numPerPage)" pagenumshown="10" currentpage="@(ViewBag.pageNum)">
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            $("select[name='sel_type']:eq(0)").find("option[value='@(ViewBag.sel_type)']").attr("selected", true);
            $("select[name='numPerPage']:eq(0)").val(@(ViewBag.numPerPage));
        });

        $.jTableTool.clickRowAction(function ($row) {
            if ($row) {
                var sole = $row.data("sole");
                if (sole != "ScmSafeAssessmentList")
                    return;
                else {
                    var state = $row.data("state");
                    //0=未上报得分，1=已上报得分
                    if (state != 0) {
                        //已经下发了
                        $("#SafetyConstruction_SafeAssessment_SafeAssessmentDelete").hide();
                        $("#SafetyConstruction_SafeAssessment_SafeAssessmentEdit").hide();
                        $("#SafetyConstruction_SafeAssessment_SafeAssessmentReport").hide();
                    } else {
                        $("#SafetyConstruction_SafeAssessment_SafeAssessmentDelete").show();
                        $("#SafetyConstruction_SafeAssessment_SafeAssessmentEdit").show();
                        $("#SafetyConstruction_SafeAssessment_SafeAssessmentReport").show();
                    }
                }

            }
        });
    </script>
</div>
